yányào.com

Recent posts

Oct 25, 2016
Leonard Cohen - you want it darker年度最佳 you want it darker 循环听了好几天 干净低沉的嗓音加配乐 愈发担心以后听不到了怎么办 😢~…
Jun 15, 2016
web audio照文档撸了一下 AudioContext 可视化音频 桌面浏览器上 Safari 9, Chrome stable 绘制正常 移动端只有微信的 webview 能工作, 纯玩票叻 ref: https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Visualizations_with_Web_Audio_API <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no"> <title>AV</title> </head> <body> <canvas id="vis"></canvas> <audio id="av" src="YOUR_AUDIO_FILE"></audio> <script src="index.js"></script> </body> </html> window.AudioContext = window.AudioContext || window.webkitAudioContext || window.mozAudioContext; window.onload = function(){ var canvas = document.getElementById('vis'); var canvasCtx = canvas.getContext('2d'); var isPlaying = true; var audio = document.getElementById('av'); var audioCtx = new AudioContext(); var analyser = audioCtx.…
Apr 26, 2016
move to caddy去年用 Hexo 搭建的日志已经好几个月没更新了,最近休假有点空闲就继续更新吧。 先从 Github 迁移回自己的 Linode,然后安装一个 Caddyserver1 来渲染 markdown Caddy is a unique web server with a modern feature set. Think nginx or Apache, but written in Go. With Caddy, you can serve your websites over HTTP/2. It can act as a reverse proxy and load balancer. Front your PHP apps with it. You can even deploy your site with git push. Cool, right?2 Download and install systemd wget -O 'caddy.…
Dec 22, 2015
mongodb backup有台机器准备2月份下架 记一个 mongodb 备份小脚本 :) #!/bin/bash # vim: set et sw=2 ts=2 sts=2 ff=unix fenc=utf8: MONGO_DATABASE="_name_" MONGO_HOST="_ip_" MONGO_PORT="_prot_" TIMESTAMP=`date +%Y-%m-%dT%H:%M:%S` MONGODUMP_PATH="/usr/bin/mongodump" BACKUPS_DIR="/data/dumps/" BACKUP_NAME="$MONGO_DATABASE-$TIMESTAMP" while test $# -gt 0 do case "$1" in -m) echo "backup mongthly and clear week_dir" #rm $BACKUPS_DIR"week/*" find $BACKUPS_DIR"week" -type f -name '*.tgz' -delete tar -czPf $BACKUPS_DIR"month/"$BACKUP_NAME.tgz $BACKUPS_DIR$MONGO_DATABASE ;; -w) echo "backup weekly" echo "tar -czPf $BACKUPS_DIR"week/"$BACKUP_NAME.tgz $BACKUPS_DIR$MONGO_DATABASE" ;; -d) echo "just dump" $MONGODUMP_PATH -d $MONGO_DATABASE --out $BACKUPS_DIR ;; *) echo "do nothing" ;; esac shift done # crontab -e 10 3 * * * /bin/bash $HOME/bin/mongobackup.…
Dec 14, 2015
let's encryptLet’s Encrypt 已经公开测试,不需要再提交测试域名表单,直接就能申请 小项目以后都能用这玩意开 https 不用花钱买证书哦啦啦 照 文档 做一遍给域名签上证书还挺简单的 # 获取项目代码 git clone https://github.com/letsencrypt/letsencrypt cd letsencrypt # 安装依赖 ./letsencrypt-auto # 获取证书 ./letsencrypt-auto certonly --standalone -d www.example.com -d example.com # 配置 nginx server { listen 443 ; ssl on; ssl_certificate_key /etc/letsencrypt/live/youdomain/privkey.pem; ssl_certificate /etc/letsencrypt/live/youdomain/fullchain.pem; } 需要注意的是 dnspod 等国内服务解析域名有问题 我这里直接切回 domains.google.com 就行了 使用 standalone 模式需要先停掉默认的 nginx 文档里提到可以使用 webroot 模式不用停 但我创建验证文件失败了 :( 默认90天过期,建议 crontab 定时更新 ###Update 使用 acme.sh An ACME protocol client written purely in Shell (Unix shell) language.…
Oct 17, 2015
simple crawler半夜看了本小说觉得翻页太累 首先要解决的问题是找一个质量还过得去的小说站 然后写个脚本去把它爬下来章节合并到一起 import fs from "fs"; import { argv } from "process"; import request from "request"; import cheerio from "cheerio"; import iconv from "iconv-lite"; import sanitize from 'sanitize-html'; class main { constructor() { Object.assign(this, { path: './chapter.json', html: './reader.html', url: { list: 'http://www.piaotian.net/html/6/6658/' }, store: [] }) } fetch(url, callback) { request.get(url, {encoding: null}, (error, response, body)=> { if (!error && response.statusCode == 200) { let $ = cheerio.load(iconv.decode(body, 'GBK')); callback($, body); } else { console.…
Oct 11, 2015
send notification when task finish终端里运行长时间任务(比如 make systemimage)的时候经常会切换到其他环境做别的事情 容易忘记查看之前的任务是否完成, 查到一些方法用在任务结束时发出通知 #C-z 切到后台运行 fg; tput bel # Mac OS X #系统弹窗 osascript -e 'tell app "System Events" to display alert "Build Completed" message "The checkout and build have completed."' say "Job finished" #语音播报 #notification center osascript -e 'display notification "Job finished" with title "Alert"' sudo gem install terminal-notifier terminal-notifier -message "Job finished!" -title "Alert" # Ubuntu notify-send "Job finished!" # KDE kdialog --passivepopup 'Job finished' 还有 iterm2 trigger 也能用来触发通知, 高亮文字…
Oct 4, 2015
create CNAME with internationalized domain name前段时间买了个 idn: yányào.com 闲置了很长时间没动 趁着十一长假无所事事的机会, 把玩了一下 hexo 挂到 yanyaoer.github.io 然后 CNAME 的时候掉坑了, 看到有人说30分钟生效傻傻等就不提了 实际上这个域名的 CNAME 内容应该用编码后的字符串而不是 yányào.com https://github.com/yanyaoer/yanyaoer.github.io/commit/7c0e4e6863904442d368e3ad5c822f8f189bb7fc#diff-adc4bfdb0829dae99e3699393e3fbaa4 diff --git a/CNAME b/CNAME index 6cb647c..92d166c 100644 --- a/CNAME +++ b/CNAME @@ -1 +1 @@ -yányào.com +xn--ynyo-2nad.com …
Oct 4, 2015
xtag-and-shadowdom最近在做的项目重构, 原本打算用 reactjs, 写了一些实验代码后心累无爱 找了个 domdiff 配合自定义标签和 shadowdom 的独有作用域也是爽 YY 可惜的是测试红米上的 android webview 版本(32?)不支持 ::shadow 伪类 inline 方式覆盖样式略嫌繁琐 示例代码 xtag.js let dom = { shadow(el) { return el.createShadowRoot ? el.createShadowRoot() : el.webkitCreateShadowRoot(); }, attr(el, prefix='') { return Object.keys(el.dataset).map((d)=> `${prefix}${d}="${el.dataset[d]}"`).join(' ') } } document.registerElement('x-image', { prototype: Object.create(HTMLElement.prototype, { createdCallback: { value() { //xtag 嵌套时这里读不到attr, 放到 attach console.log('onCreate::image'); } }, attachedCallback: { value() { console.log('onAttach::image'); let shadow = dom.shadow(this); shadow.innerHTML = `<style> img { max-width: 100%; } </style> <img ${dom.…
Jan 20, 2015
remote pbcopy with netcatQuick start while (true); do nc -l 2224 | pbcopy; done #If your laptop is running linux, replacing pbcopy with xcopy should work: #while (true); do nc -l 2224 | xcopy; done echo "This text gets sent to clipboard" | nc localhost 2224 echo "RemoteForward 2224 localhost:2224" >> ~/.ssh/config ssh remote -t 'cat blablabla | nc -q0 localhost 2224' Daemonizing pbcopy launchctl load ~/Library/LaunchAgents/local.pbcopy.plist <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.…